package org.tysite.tyservice.example.validation.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.tysite.tyservice.example.validation.dto.GroupDemoDTO;
import org.tysite.tyservice.example.validation.group.AddOperation;
import org.tysite.tyservice.example.validation.group.ModifyOperation;

/**
 * 演示分组验证功能的API入口
 * @author tysite
 * @date 2020/3/22 0022 15:13
 */
@RestController
@RequestMapping("/api/example/validation/group")
public class ValidationGroupController {
    
    @PostMapping("/add")
    public GroupDemoDTO insertDemo(@Validated({AddOperation.class}) @RequestBody GroupDemoDTO dto) {
        return dto;
    }
    
    @PutMapping("/update")
    public GroupDemoDTO modifyDemo(@Validated({ModifyOperation.class}) @RequestBody GroupDemoDTO dto) {
        return dto;
    }
}
